<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    

       <script>  

        /*
             new的用法
                
        function Person(name,age){
            this.name=name
            this.age=age  
            this.sayWorld=function(){
                   console.log('我是'+this.name+'今年'+this.age)
            }
        }

         let pp=new Person('xiaoming',18)
         pp.sayWorld()
         console.log(pp)
         */

         /*
           1.声明一个对象
           2.链接到原型
           3.绑定到this 执行构造函数
           4.返回一个对象

         */

         function Person(name,age){
            this.name=name
            this.age=age  
            this.sayWorld=function(){
                   console.log('我是'+this.name+'今年'+this.age)
            }
        }

         function newNew(fm,...arg){
            let objObj={}
            objObj.__proto__=fm.prototype
            fm.call(objObj,...arg)
            return  objObj

         }

         let pp= newNew(Person,'xiaoming',18)
         pp.sayWorld()
         console.log(pp)
         


     

       </script>

</body>
</html>